﻿/*
*   学员端入口
*/
// 主页内容
jisuStuApp.controller('home', ['$scope', function ($scope) {

} ]);
jisuStuApp.controller('trainController', ['$scope', '$state', '$rootScope', '$sce', '$translate', '$location', 'sysUserInfo', 'Restangular',function ($scope, $state, $rootScope, $sce, $translate, $location, sysUserInfo, Restangular) {

    // 二级菜单
    $rootScope.twoMenuList = [];
    //$rootScope.parstr = "home.train";
    angular.forEach($rootScope.stuMenuList, function (menu, index) {
        if (menu.id == "f1a75ec21133ece9108585b87c611dfa") {
            $rootScope.twoMenuList = menu.children;
        }
    });
    // 地址
    $rootScope.parstr = $location.path().split('/').join('.');
    $rootScope.parstr = $rootScope.parstr.substr(1, $rootScope.parstr.length - 1);
    if ($rootScope.parstr == 'home.train') {
        $rootScope.twoparstr = $rootScope.twoMenuList[0].url;
        $state.go($rootScope.twoparstr);
    } else {
        var urlFlag = true;
        angular.forEach($rootScope.twoMenuList, function (menu, index) {
            if (menu.url == $rootScope.parstr) {
                urlFlag = false;
            }
        });
        // 还没有查询出来就到这了
        if ($rootScope.twoMenuList.length == 0) {
            $state.go('home');
        }
        if (urlFlag) {
            $rootScope.twoparstr = $rootScope.twoMenuList[0].url;
            $state.go($rootScope.twoparstr);
        } else {
            $rootScope.twoparstr = angular.copy($rootScope.parstr);
            $state.go($rootScope.twoparstr);
            $rootScope.parstr = 'home.train';
        }

    }
    $scope.playUrl = function (val) {
        //子菜单
        if (val.indexOf('home.train') != -1) {
            $rootScope.parstr = "home.train";
            $rootScope.twoparstr = val;
        } else if (val == "home.stuinfo.coursecollection" || val == "home.stuinfo.examhistory"
        || val == "home.stuinfo.gerenxinxi") {
            $rootScope.parstr = "home.stuinfo";
            $rootScope.twoparstr = val;
            //默认选择第一个
        } else if (val == "home.stuinfo") {
            $rootScope.twoparstr = "home.stuinfo.coursecollection";
            $rootScope.parstr = "home.stuinfo";
            //主菜单
        } else {
            $rootScope.parstr = val;
        }
    }
} ]);
//荣誉
jisuStuApp.controller('honorController', ['$scope', '$state', '$rootScope', '$sce', '$translate', '$location', 'sysUserInfo', 'Restangular', function ($scope, $state, $rootScope, $sce, $translate, $location, sysUserInfo, Restangular) {

    // 二级菜单
    $rootScope.twoMenuList = [];
    //$rootScope.parstr = "home.train";
    angular.forEach($rootScope.stuMenuList, function (menu, index) {
        if (menu.id == "b9c6a0174133edb19d16e930b26d5a44") {
            $rootScope.twoMenuList = menu.children;
        }
    });
    // 地址
    $rootScope.parstr = $location.path().split('/').join('.');
    $rootScope.parstr = $rootScope.parstr.substr(1, $rootScope.parstr.length - 1);
    if ($rootScope.parstr == 'home.honor') {
        $rootScope.twoparstr = $rootScope.twoMenuList[0].url;
        $state.go($rootScope.twoparstr);
    } else {
        var urlFlag = true;
        angular.forEach($rootScope.twoMenuList, function (menu, index) {
            if (menu.url == $rootScope.parstr) {
                urlFlag = false;
            }
        });
        // 还没有查询出来就到这了
        if ($rootScope.twoMenuList.length == 0) {
            $state.go('home');
        }
        if (urlFlag) {
            $rootScope.twoparstr = $rootScope.twoMenuList[0].url;
            $state.go($rootScope.twoparstr);
        } else {
            $rootScope.twoparstr = angular.copy($rootScope.parstr);
            $state.go($rootScope.twoparstr);
            $rootScope.parstr = 'home.honor';
        }

    }
    $scope.playUrl = function (val) {
        //子菜单
        if (val.indexOf('home.honor') != -1) {
            $rootScope.parstr = "home.honor";
            $rootScope.twoparstr = val;
        } else if (val == "home.stuinfo.coursecollection" || val == "home.stuinfo.examhistory"
        || val == "home.stuinfo.gerenxinxi") {
            $rootScope.parstr = "home.stuinfo";
            $rootScope.twoparstr = val;
            //默认选择第一个
        } else if (val == "home.stuinfo") {
            $rootScope.twoparstr = "home.stuinfo.coursecollection";
            $rootScope.parstr = "home.stuinfo";
            //主菜单
        } else {
            $rootScope.parstr = val;
        }
    }
} ]);
// 导航
jisuStuApp.controller('topbarController', ['$scope', 'Msg', 'Comm', 'MsgCon', '$rootScope', '$sce', '$state', '$translate', '$location', 'sysUserInfo', 'Restangular', 'StuRequestTrain', function ($scope, Msg, Comm, MsgCon, $rootScope, $sce, $state, $translate, $location, sysUserInfo, Restangular, ST) {
    $scope.userInfo = sysUserInfo.getuserinfo();
    $scope.orgname = sysUserInfo.getuserinfo().organization_Name;
    var domainName = window.location.hostname; //获取域名
    //不是分销人员
    // $scope.showDistrbition = false;
    // //是否显示跳转分销
    // if ($scope.userInfo.powerLV == '99') {
    //     if ($scope.userInfo.hasOwnProperty('userContact')) {
    //         //是分销人员
    //         if ($scope.userInfo.userContact.hasOwnProperty("distributionLevel")) {
    //             $scope.showDistrbition = true;
    //         }
    //     }
    //     //管理员教师分销
    // }
    //自己的
    if (domainName != $rootScope.domain) {
        $scope.logo = sysUserInfo.getorganizationinfo().organization_mainlogo;
    }
    // 地址
    $rootScope.parstr = $location.path().split('/').join('.');
    $rootScope.parstr = $rootScope.parstr.substr(1, $rootScope.parstr.length - 1);
    //子菜单
    if ($rootScope.parstr == "home.stuinfo.coursecollection" || $rootScope.parstr == "home.stuinfo.examhistory"
        || $rootScope.parstr == "home.stuinfo.gerenxinxi") {
        $rootScope.twoparstr = $rootScope.parstr;
        $rootScope.parstr = "home.stuinfo";
    }

    // 主站地址
    $scope.url = $sce.trustAsResourceUrl($rootScope.userurl + "/api/v2tov1?username=" + sysUserInfo.getuserinfo().user_Account + "&passwd=" + sysUserInfo.getuserinfo().user_Pwd);

    //退出登录
    $scope.exituserinfo = function () {
        //        Restangular.one("/organizationInfo").customPOST({ name: "My Message" }, "findOrgInfo", { orgId: sysUserInfo.getuserinfo().organization_ID }).then(function (response) {
        //            var url = "//" + $rootScope.domain + "/login.html?signout=0";
        //            if (response.errorcode == "0") {
        //                if (response.data.organization_domain_name != null && response.data.organization_domain_name != "" && response.data.organization_domain_name != undefined) {
        //                    $scope.url = response.data.organization_domain_name;
        //                } else if (response.data.organization_two_domain_name != null && response.data.organization_two_domain_name != "" && response.data.organization_two_domain_name != undefined) {
        //                    $scope.url = response.data.organization_two_domain_name + $rootScope.shortdomain;
        //                } else {
        //                    $scope.url = $rootScope.domain;
        //                }
        //            }
        //            //开始跳转
        //            url = "http://" + $scope.url + "?signout=0";
        //            sysUserInfo.clearuserinfo(url);
        //        }, function () { sysUserInfo.clearuserinfo("//" + $rootScope.domain + "/login.html?signout=0"); });
        sysUserInfo.clearuserinfo($scope.url);
    }
    //跳转网校
    $scope.goWx = function () {
        location.href = $scope.wxdomain;
    }
    $scope.wxdomain = "";//网校的域名
    $scope.orginfo = sysUserInfo.getorganizationinfo();
    if (!Comm.isNull($scope.orginfo.organization_domain_name)) {
        $scope.url ="//"+ $scope.orginfo.organization_domain_name;
        $scope.wxdomain = "//" + $scope.orginfo.organization_domain_name;
    } else if (!Comm.isNull($scope.orginfo.organization_two_domain_name)) {
        $scope.url = "//" + $scope.orginfo.organization_two_domain_name + $rootScope.shortdomain;
        $scope.wxdomain = "//" + $scope.orginfo.organization_two_domain_name + $rootScope.shortdomain;
    } else {
        $scope.url = "//" + $rootScope.domain;
    }

    $scope.playUrl = function (val) {
        //子菜单
        if (val.indexOf('home.train') != -1) {
            $rootScope.parstr = "home.train";
            angular.forEach($rootScope.stuMenuList, function (menu, index) {
                if (menu.id == "f1a75ec21133ece9108585b87c611dfa") {
                    $rootScope.twoMenuList = menu.children;
                }
            });
            if ($rootScope.twoMenuList && $rootScope.twoMenuList.length > 0) {
                $rootScope.twoparstr = $rootScope.twoMenuList[0].url;
                val = $rootScope.twoMenuList[0].url;
            } else {
                val = $rootScope.parstr
            }
        } else if (val == "home.stuinfo.coursecollection" || val == "home.stuinfo.examhistory"
        || val == "home.stuinfo.gerenxinxi") {
            $rootScope.parstr = "home.stuinfo";
            $rootScope.twoparstr = val;
            //默认选择第一个
        } else if (val == "home.stuinfo") {
            $rootScope.twoparstr = "home.stuinfo.coursecollection";
            $rootScope.parstr = "home.stuinfo";
            //荣誉
        } else if (val.indexOf('home.honor') != -1) {
            $rootScope.parstr = "home.honor";
            angular.forEach($rootScope.stuMenuList, function (menu, index) {
                if (menu.id == "b9c6a0174133edb19d16e930b26d5a44") {
                    $rootScope.twoMenuList = menu.children;
                }
            });
            if ($rootScope.twoMenuList && $rootScope.twoMenuList.length > 0) {
                $rootScope.twoparstr = $rootScope.twoMenuList[0].url;
                val = $rootScope.twoMenuList[0].url;
            } else {
                val = $rootScope.parstr
            }
            //主菜单
        } else {
            $rootScope.twoparstr = val;
            $rootScope.parstr = val;
        }
        $state.go(val);
    }

    $scope.userinfoo = sysUserInfo.getuserinfo();
    //国际化
    $scope.switching = function (lang) {
        $translate.use(lang);
        window.localStorage.lang = lang;
        window.location.reload();
    };
    /*******************最近七天的提醒**********************/
    $scope.nowCount = 3;
    //展开全部
    $scope.showMore = function () {
        $scope.nowCount = 7;
    }
    $scope.showTx = false;

    // 所有的userid
    $scope.allUserinfo = sysUserInfo.getuserinfo();

    $scope.token = sysUserInfo.getuserinfotoken();
    //参数处理
    if ($scope.allUserinfo.userOrgList != undefined && $scope.allUserinfo.userOrgList.length > 0) {
        //组织结构 ID 字符串
        for (var i = 0; i < $scope.allUserinfo.userOrgList.length; i++) {
            $scope.allUserinfo.orgStr += $scope.allUserinfo.userOrgList[i]["organization_ID"] + ",";
        }
    }
    //权限 ID 字符串
    if ($scope.allUserinfo.userRoleList != undefined && $scope.allUserinfo.userRoleList.length > 0) {
        for (var i = 0; i < $scope.allUserinfo.userRoleList.length; i++) {
            $scope.allUserinfo.roleStr += $scope.allUserinfo.userRoleList[i]["roles_ID"] + ",";
        }
    }
    //用户组 ID 字符串
    if ($scope.allUserinfo.userGroupList != undefined && $scope.allUserinfo.userGroupList.length > 0) {
        for (var i = 0; i < $scope.allUserinfo.userGroupList.length; i++) {
            $scope.allUserinfo.groupStr += $scope.allUserinfo.userGroupList[i]["userGroup_ID"] + ",";
        }
    }
    // 个人信息的请求参数
    $scope.userInfoParam = {
        userid: $scope.allUserinfo.user_ID,
        orgid: $scope.allUserinfo.organization_ID,
        org_Id: $scope.allUserinfo.orgStr,
        role_Id: $scope.allUserinfo.roleStr,
        user_groupId: $scope.allUserinfo.groupStr
    }

    // //最近的消息提醒
    // $scope.messageCount = 0;

    // //查询的参数
    // $scope.msgparams = {
    //     xid: "",
    //     type: "",
    //     recipientId: sysUserInfo.getuserinfo().user_ID,
    //     sendMode: "5",
    //     pageIndex: 1,
    //     pageSize: 10,
    //     numCount: 0
    // };
    // $scope.Loading = false;


    // //查询列表
    // $scope.getMessageCount = function () {
    //     //$scope.Loading = true;
    //     ST.findMessagePage($scope.msgparams).success(function (response) {
    //         $scope.Loading = false;
    //         if (response.errorcode == "0") {
    //             if (response.numCount == undefined) {
    //                 $scope.messageCount = 0;
    //             } else {
    //                 $scope.messageCount = response.numCount;
    //             }
    //         } else {
    //             Msg.error("查询异常!")
    //         }
    //     }, function errorCallback() {
    //         $scope.Loading = false;
    //         console.log("连接服务器失败！");
    //     });
    // }
    //$scope.getMessageCount();

    /*****************************************************************************************************************************/
    $scope.updateOrgList = []; //可切换的企业
    $scope.upcode = "";
    $scope.getCanUpdateOrg = function () {
        ST.findUserOrg({ userid: $scope.userinfoo.user_ID }).then(function (data) {
            if (data.errorcode == 0 && data.datas.length > 0) {
                $scope.updateOrgList = data.datas;
                $scope.upcode = data.code;
            }
        }, function (data) {
            $scope.islivebtnload = false;
            Msg.error('连接服务器失败！');
        })
    }
    //$scope.getCanUpdateOrg();
    //切换企业
    $scope.UpdateOrg = function (item) {
        MsgCon.delnoicon("提示", "确认切换到’" + item.orgName + "‘企业吗？", "", "确定", "继续").then(function (data) {
            if (data) {
                $scope.Loading = true;
                ST.modifyUserOrg({ userid: $scope.userinfoo.user_ID, orgid: item.orgId, code: $scope.upcode }).then(function (data) {
                    if (data.errorcode == 0) {
                        Msg.success("企业切换成功，即将重新登录！");
                        setTimeout(function () {
                            location.href = "/test_login.html#" + $scope.userinfoo.user_ID + "/" + sysUserInfo.getuserinfotoken();
                        }, 3000);
                    }
                }, function (data) {
                    $scope.islivebtnload = false;
                    Msg.error('连接服务器失败！');
                })
            }
        });

    }
} ]);
// 首页
angular.module('jisuStuHome').controller('homeController', ['$rootScope', '$scope', '$state', 'StuRequestTrain', 'sysUserInfo', 'Msg', 'T', 'interlocutionservice', function ($rootScope, $scope, $state, ST, sysUserInfo, Msg, T, IS) {
    // 选择路径
    $scope.playUrl = function (val) {
        //子菜单
        if (val.indexOf('home.train') != -1) {
            $rootScope.parstr = "home.train";
        } else if (val == "home.stuinfo.coursecollection" || val == "home.stuinfo.examhistory"
        || val == "home.stuinfo.gerenxinxi") {
            $rootScope.parstr = "home.stuinfo";
            $rootScope.twoparstr = val;
            //默认选择第一个
        } else if (val == "home.stuinfo") {
            $rootScope.twoparstr = "home.stuinfo.coursecollection";
            $rootScope.parstr = "home.stuinfo";
            //主菜单
        } else {
            $rootScope.parstr = val;
        }
    }

    // 所有的userid
    $scope.allUserinfo = sysUserInfo.getuserinfo();

    $scope.token = sysUserInfo.getuserinfotoken();
    //参数处理
    if ($scope.allUserinfo.userOrgList != undefined && $scope.allUserinfo.userOrgList.length > 0) {
        //组织结构 ID 字符串
        for (var i = 0; i < $scope.allUserinfo.userOrgList.length; i++) {
            $scope.allUserinfo.orgStr += $scope.allUserinfo.userOrgList[i]["organization_ID"] + ",";
        }
    }
    //权限 ID 字符串
    if ($scope.allUserinfo.userRoleList != undefined && $scope.allUserinfo.userRoleList.length > 0) {
        for (var i = 0; i < $scope.allUserinfo.userRoleList.length; i++) {
            $scope.allUserinfo.roleStr += $scope.allUserinfo.userRoleList[i]["roles_ID"] + ",";
        }
    }
    //用户组 ID 字符串
    if ($scope.allUserinfo.userGroupList != undefined && $scope.allUserinfo.userGroupList.length > 0) {
        for (var i = 0; i < $scope.allUserinfo.userGroupList.length; i++) {
            $scope.allUserinfo.groupStr += $scope.allUserinfo.userGroupList[i]["userGroup_ID"] + ",";
        }
    }
    // 个人信息的请求参数
    $scope.userInfoParam = {
        userid: $scope.allUserinfo.user_ID,
        orgid: $scope.allUserinfo.organization_ID,
        org_Id: $scope.allUserinfo.orgStr,
        role_Id: $scope.allUserinfo.roleStr,
        user_groupId: $scope.allUserinfo.groupStr
    }
    $scope.resUserInfo = {};
    // 获取个人统计信息
    ST.stuTotleInfo($scope.userInfoParam).then(function (response) {
        if (response.errorcode == "0") {
            $scope.resUserInfo = response.data;
        } else {
            Msg.error("错误", "获取人员信息失败！");
        }
    }, function () {
        Msg.error("错误", "服务器连接失败！");
    });
    $scope.courseList = [];
    // 查询最近学习的前三个课程
    ST.studyCourseTopThree({ userid: $scope.allUserinfo.user_ID, pageSize: 3 }).then(function (response) {
        if (response.errorcode == "0") {
            $scope.courseList = response.datas;
        } else {
            Msg.error("错误", "获取近期课程列表失败！");
        }
    });
    $scope.fileParams = {
        xid: $scope.allUserinfo.orgStr + $scope.allUserinfo.roleStr + $scope.allUserinfo.groupStr + $scope.allUserinfo.user_ID,
        orgid: $scope.allUserinfo.organization_ID
    }

    $scope.fileList = [];
    //    // 共享文件
    //    ST.getTopSixShareList($scope.fileParams).then(function (response) {
    //        if (response.errorcode == "0") {
    //            $scope.fileList = response.datas;
    //        } else {
    //            Msg.error("错误", "共享文件列表获取失败！")
    //        }
    //    });
    // 判断图片是否存在
    $scope.isImg = function (pathImg) {
        var ImgObj = new Image();
        ImgObj.src = pathImg;
        if (ImgObj.fileSize > 0 || (ImgObj.width > 0 && ImgObj.height > 0)) {
            return true;
        } else {
            return false;
        }
    }

    //文件预览 
    $scope.isFilePreview = { divhide: false, data: {} };
    // 文件预览
    $scope.filePreview = function (item) {
        if (item.hasOwnProperty('fileType'))
            if (item.fileType.toLowerCase() == 'ques' || item.fileType.toLowerCase() == 'wxt' || item.fileType.toLowerCase() == 'urls') {
                Msg.info('提示', '此文件请在知识库内操作');
                $state.go('home.knowledge');
                $rootScope.parstr = '/home/knowledge';
                return;
            }
        $scope.isFilePreview.divhide = true;
        $scope.isFilePreview.data = item;
        item.previewNumber = parseInt(item.previewNumber) + 1;
        $scope.pvParams = { fileid: item.upId, orgid: $scope.allUserinfo.organization_ID, userid: $scope.allUserinfo.user_ID, previewNumber: item.previewNumber };
        ST.PreviewNumber($scope.pvParams).then(function (kbdata) {
            if (kbdata.errorcode == "0") {
            } else {
                console.log("失败了！");
            }
        });
    }

    /************************************************公告****************************************************************/
    $scope.noticeInfo = [];
    $scope.noticeTop = null;
    $scope.noticeParam = { pageSize: 5, pageIndex: 1, orgid: sysUserInfo.getuserinfo().organization_ID };
    $scope.showCourse = 1; //默认展示课程
    $scope.getNoticeList = function () {
        ST.findStudentNotice($scope.noticeParam).then(function (response) {
            if (response.errorcode == "0") {
                if (response.datas.length > 0) {
                    $scope.noticeInfo = response.datas;
                    if ($scope.noticeParam.pageIndex == 1) {
                        $scope.noticeTop = $scope.noticeInfo[0];
                        $scope.noticeTop.index = 1;
                    }
                    $scope.paginationConf.totalItems = (response.numCount == undefined ? response.datas.length : response.numCount);
                    $scope.paginationConf.currentPage = (response.pageIndex == undefined ? 1 : response.pageIndex);
                }
            } else {
                Msg.error("错误", "获取公告信息失败！");
            }
        });
    }
    $scope.showNotice = function (item, index) {
        item.index = index;
        $scope.noticeTop = item;
    }
    // 紧急任务加粗
    $scope.newStyle = function (item) {
        if (item) {
            return {
                "color": "red",
                "font-weight": "bold"
            };
        }
    }
    //配置分页
    $scope.paginationConf = {
        currentPage: 1, //$location.search().currentPage ? $location.search().currentPage :  当前页码
        totalItems: 0,  // 总的记录数
        itemsPerPage: 5, // 每页显示多少条        
        perPageOptions: [5],   // 每页显示记录数        
        onChange: function () {
            $scope.paginationConf.currentPage = $scope.paginationConf.currentPage == 0 ? 1 : $scope.paginationConf.currentPage;
            if ((parseInt($scope.noticeParam.pageIndex) != parseInt($scope.paginationConf.currentPage)) || (parseInt($scope.noticeParam.pageSize) != parseInt($scope.paginationConf.itemsPerPage))) {
                if ($scope.paginationConf.currentPage == 0) { $scope.paginationConf.currentPage = 1; }
                $scope.noticeParam.pageIndex = $scope.paginationConf.currentPage;
                $scope.noticeParam.pageSize = $scope.paginationConf.itemsPerPage;
                $scope.getNoticeList();
            }
        }
    };
    $scope.getNoticeList();
    /*************************************************任务*****************************************************************/
    $scope.stuTrainLoading = false;
    //参数
    $scope.stuListParams = {
        orgID: sysUserInfo.getuserinfo().organization_ID,
        user_id: sysUserInfo.getuserinfo().user_ID,
        state: '1',
        org_Id: "",  // 用户组织机构
        role_Id: "", // 角色 
        user_groupId: "", //用户组
        orderType: "2", //1.名称 2.时间
        pageSize: 3,    // 10条 预留
        pageIndex: 1     // 页数
    }
    // 初始化担当前人的信息
    // 部门
    angular.forEach(sysUserInfo.getuserinfo().userOrgList, function (data, index, array) {
        $scope.stuListParams.org_Id += ($scope.stuListParams.org_Id.length <= 0 ? "" : ",") + data.organization_ID;
    });
    //角色 
    angular.forEach(sysUserInfo.getuserinfo().userRoleList, function (data, index, array) {
        $scope.stuListParams.role_Id += ($scope.stuListParams.role_Id.length <= 0 ? "" : ",") + data.roles_ID;
    });
    //用户组
    angular.forEach(sysUserInfo.getuserinfo().userGroupList, function (data, index, array) {
        $scope.stuListParams.user_groupId += ($scope.stuListParams.user_groupId.length <= 0 ? "" : ",") + data.userGroup_ID;
    })

    //获取学员 任务列表
    $scope.getStuTrainList = function () {
        if ($scope.stuTrainLoading)
            return; //禁止狂点
        $scope.stuTrainLoading = true;
        //请求数据
        ST.findStudentStage($scope.stuListParams).then(function (response) {
            $scope.stuTrainLoading = false;
            if (response.errorcode == "0") { // 成功                
                $scope.stuTrainList = response.datas;
                $scope.stuTrainList.forEach(function (data, index) {
                    data.completeCount = parseFloat(data.completeCount);
                    data.courser_count = parseFloat(data.courser_count);
                });
            } else {
                Msg.error('数据请求失败！');
            }
        }, function errorCallback() {
            console.log("连接服务器失败！");
        });
    }
    //$scope.getStuTrainList();
    /***************************************************************公开课*********************************************************************/
    // 获取公开的请求参数
    $scope.publicCourseParams = {
        // 企业id
        orgid: sysUserInfo.getuserinfo().organization_ID,
        userid: sysUserInfo.getuserinfo().user_ID,
        searchType: 1,   // 排序类型 1.创建时间 2.观看数量 3.收藏数量
        pageIndex: 1,    // 当前页数
        pageSize: 4 // 单页条数
    }
    // 返回公开课的集合
    $scope.publicCourseList = [];
    // 获取公开课
    $scope.getPublicCourseList = function () {
        // 发送请求
        ST.findOpen($scope.publicCourseParams).then(function (response) {
            if (response.errorcode == 0) {
                $scope.publicCourseList = response.datas;
            } else {
                Msg.error("错误", "获取公开课失败！")
            }
        });
    }
    $scope.getPublicCourseList();
    /*******************************************************************************************************************************/
    //打开课程
    $scope.openKe = function (item) {
        if (!item.isExpire) {
            var url = "";
            if ($rootScope.fileurl.indexOf("http") != -1) {
                url = $rootScope.upurl + '/dispatcher/redirect?url=' + encodeURI(encodeURI($rootScope.fileurl + "/resources/template/" + item.courseId + ".html&arrangeId=" + (item.hasOwnProperty("arrangeId") ? item.arrangeId : "") + "&token=" + $scope.token));
            } else {
                url = $rootScope.upurl + '/dispatcher/redirect?url=' + encodeURI(encodeURI(window.location.protocol + $rootScope.fileurl + "/resources/template/" + item.courseId + ".html&arrangeId=" + (item.hasOwnProperty("arrangeId") ? item.arrangeId : "") + "&token=" + $scope.token));
            }
            window.open(url);
        } else {
            Msg.warning("课程已过期！");
        }
    }
    //打开公开课课程
    $scope.openPubKe = function (item) {
        var url = "";
        if ($rootScope.fileurl.indexOf("http") != -1) {
            url = $rootScope.upurl + '/dispatcher/redirect?url=' + encodeURI(encodeURI($rootScope.fileurl + "/resources/template/" + item.course_Id + ".html&arrangeId=1&token=" + $scope.token));
        } else {
            url = $rootScope.upurl + '/dispatcher/redirect?url=' + encodeURI(encodeURI(window.location.protocol + $rootScope.fileurl + "/resources/template/" + item.course_Id + ".html&arrangeId=1&token=" + $scope.token));
        }
        window.open(url);
    }
    /*************************************************************************************************************************************/
    // 任务预览
    $scope.previewShow = false;
    $scope.previewObj = {};
    // 任务详细页面
    $scope.taskPreview = function (taskObj) {
        $scope.previewShow = true;
        $scope.previewObj = taskObj;
    }

    $scope.closePreview = function () {
        $scope.previewShow = false;
    }
    /*****************************************************************************************************************************************/
    // $scope.competitionList = [];
    // $scope.getCompetitionList = function () {
    //     IS.findStudentCompetition({ count: 1, orgid: sysUserInfo.getuserinfo().organization_ID }).then(function (response) {
    //         if (response.errorcode == "0") {
    //             $scope.competitionList = response.datas;
    //         } else {
    //             Msg.error("错误", "获取提醒信息失败！");
    //         }
    //     });
    // }
    // $scope.getCompetitionList();

    //***************************************************图像采集**************************************************、
    // $scope.imgcjShow = false;
    // //关闭
    // $scope.openImgCj = function () {
    //     $scope.imgcjShow = !$scope.imgcjShow;
    // }
    
    // //获取图像采集开关
    // $scope.getSwitch = function () {
    //     // 发送请求
    //     ST.getOrgSwitch({ switchs: "switchs_img_cj", "orgid": sysUserInfo.getuserinfo().organization_ID }).then(function (response) {
    //         $scope.examHistoryLoading = false;
    //         if (response.errorcode == "0") {
    //             //开启开关，并且无原始图
    //             if (response.data != undefined && response.data != null && response.data.is_switch != undefined && response.data.is_switch == 0) {
    //                 //回显原始图
    //                 if (sysUserInfo.getuserinfo().userContact != undefined && sysUserInfo.getuserinfo().userContact.facePhoto == undefined) {
    //                     $scope.openImgCj();
    //                 }
    //             }
    //         } else {
    //             Msg.error("错误", "服务器异常");
    //         }
    //     }, function errorCallback() {
    //         console.log("连接服务器失败！");
    //     });
    // }
    //$scope.getSwitch();
} ]);
  
